package com.mes.task.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.Where;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Dept;
import com.mes.basicdata.domain.Device;
import com.mes.basicdata.domain.Operation;
import com.mes.basicdata.domain.Part;
import com.mes.basicdata.domain.Routing;
import com.mes.basicdata.domain.TypesData;
import com.mes.basicdata.domain.WorkCenter;
import com.mes.common.domain.BasicModel;

/**
 * <p>
 * OperationTask 工序任务
 * </p>
 * 
 */
@Entity()
@Table(name = "T_TASKS")
@Where(clause = "tasktype like '2%'")
@BatchSize(size = 20)
@Lazy(value = true)
// @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class OperationTask extends BasicModel {

	public static interface DispatchGrade {
		public final int NEED_DISPATCH = 1; // 必须工长派工
		public final int CAN_DISPATCH = 2; // 可以工长派工也可以工人直接领取
		public final int NOT_DISPATCH = 3; // 不需要派工，工人直接领取
		public final int DIRECT_FEEDBACK = 4; // 直接由工人反馈
	}

	public final static int TASKSTATE_DRAG = 201; // 草稿
	public final static int TASKSTATE_PREASSIGNED = 204; // 已分解
	public final static int TASKSTATE_READY = 205; // 已计划
	public final static int TASKSTATE_DISPATCHED = 206; // 已投产
	public final static int TASKSTATE_STARTED = 207; // 已开始
	public final static int TASKSTATE_COMPLETED = 209; // 已完成加工
	public final static int TASKSTATE_CANCELED = 210; // 已取消
	public final static int TASKSTATE_DELIVERIED = 211; // 工序已交付入库

	public final static String TASKTYPE_NORMAL = "201"; // 正常工序
	public final static String TASKTYPE_CHECK = "202"; // 检验工序
	public final static String TASKTYPE_TEMP = "204"; // 临时工序
	public final static String TASKTYPE_SAMPLE = "205"; // 试样工序

	@Id
	@GenericGenerator(name = "taskUid", strategy = "assigned")
	@Column(name = "TASKUID")
	protected String taskUid;

	@Column(name = "TASKNAME")
	protected String taskName;

	// 任务号或者计划号
	@Column(name = "TASKID")
	protected String taskId;

	@Column(name = "PARENTUID")
	protected String parentTaskUid;
	// many-to-one
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PARENTUID", insertable = false, updatable = false)
	protected PartTask partTask;

	@Column(name = "SCHEDULESTART")
	protected Date scheduleStart;

	@Column(name = "SCHEDULEFINISH")
	protected Date scheduleFinish;

	@Column(name = "PLANSTART")
	protected Date planStart;

	@Column(name = "PLANFINISH")
	protected Date planFinish;

	@Column(name = "BASESTART")
	protected Date baseStart;

	@Column(name = "BASEFINISH")
	protected Date baseFinish;

	@Column(name = "ACTUALSTART")
	protected Date actualStart;

	@Column(name = "ACTUALFINISH")
	protected Date actualFinish;

	@Column(name = "EARLYSTART")
	protected Date earlyStart;

	@Column(name = "EARLYFINISH")
	protected Date earlyFinish;

	@Column(name = "LATESTART")
	protected Date lateStart;

	@Column(name = "LATEFINISH")
	protected Date lateFinish;

	@Column(name = "CONSTRAINTTYPE")
	protected Integer constraintType;

	@Column(name = "CONSTRAINTDATE")
	protected Date constraintDate;

	@Column(name = "TASKWORK")
	protected Float taskWork;

	@Column(name = "ESTITASKWORK")
	protected Float estiTaskWork;

	@Column(name = "COMPLETEWORK")
	protected Float completeWork;

	@Column(name = "TASKTYPE")
	protected String taskType;
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumnsOrFormulas(value = {
//			@JoinColumnOrFormula(column = @JoinColumn(name = "TASKTYPE", referencedColumnName = "ID", nullable = true, insertable = false, updatable = false)),
//			@JoinColumnOrFormula(formula = @JoinFormula(value = "'tasktype'", referencedColumnName = "TYPESNAME")) })
//	protected TypesData taskTypeDesc;

	@Column(name = "TASKSTATE")
	protected Integer taskState;
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumnsOrFormulas(value = {
//			@JoinColumnOrFormula(column = @JoinColumn(name = "TASKSTATE", referencedColumnName = "ID", nullable = true, insertable = false, updatable = false)),
//			@JoinColumnOrFormula(formula = @JoinFormula(value = "'taskstate'", referencedColumnName = "TYPESNAME")) })
//	protected TypesData taskStateDesc;

	@Column(name = "PRIORITY")
	protected Integer priority;

	@Column(name = "COMPLETEPERCENT", precision = 25, scale = 6)
	protected Float completePercent;

	/******************* 以上为Task的基本属性定义 *************************/

	// Part
	@Column(name = "PART_NUMBER")
	protected String partUid;
	// many-to-one
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PART_NUMBER", insertable = false, updatable = false)
	protected Part part;

	// 对应物料的图号
	@Column(name = "PART_DRAWINGID")
	protected String partDrawingId;
	// 对应物料的名称
	@Column(name = "PART_NAME")
	protected String partName;
	// 对应物料的版次
	@Column(name = "PART_VERSIONID")
	protected String partVersionId;

	// 型号
	@Column(name = "MODEL")
	protected String model;

	// 批次
	@Column(name = "BATCHNUM")
	protected String batchNum;

	// 架次号
	@Column(name = "CONTIGNATION_NUMBER")
	protected String contignationNumber;

	// 工序号
	@Column(name = "OPERATION_IDDESC")
	protected String operationIdDesc;

	// 工序排序号
	@Column(name = "OPERATION_ID")
	protected Float operationId;
	
	@Column(name = "PLANQTY", precision = 25, scale = 6)
	protected Float planQty;

	@Column(name = "DUEQTY", precision = 25, scale = 6)
	protected Float dueQty;

	@Column(name = "COMPLETEQTY", precision = 25, scale = 6)
	protected Float completeQty;

	// 合格数量
	@Column(name = "CHECK1QTY", precision = 10)
	private Float noDefectQty;
	// 返工数量
	@Column(name = "CHECK2QTY", precision = 10)
	private Float reworkQty;
	// 返修数量
	@Column(name = "CHECK3QTY", precision = 10)
	private Float repairQty;
	// 报废数量
	@Column(name = "CHECK8QTY", precision = 10)
	protected Float rejectQty;

	// 试样数量
	@Column(name = "TRYQTY")
	protected Float tryQty;

	@Column(name = "PREOPTIME")
	protected Float preOpTime;

	@Column(name = "RUNTIME")
	protected Float runTime;

	@Column(name = "POSTOPTIME")
	protected Float postOpTime;

	@Column(name = "ESTIPRETIME")
	private Float estiPreOpTime;

	@Column(name = "ESTIRUNTIME")
	private Float estiRunTime;

	/**
	 * 请制部门
	 */
	@Column(name="DEPTID")
	protected String deptUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEPTID",insertable=false,updatable=false)
	protected Dept dept;

	/**
	 * 主制部门
	 */
	@Column(name="MASTERSHOP")
	protected String masterShopUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="MASTERSHOP",insertable=false,updatable=false)
	protected Dept masterShop;
	
	@Column(name = "OPUID")
	protected String operationUid;
	// many-to-one
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "OPUID", insertable = false, updatable = false)
	protected Operation operation;

	@Column(name="ROUTING")
	protected String routingUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ROUTING",insertable=false,updatable=false)
	protected Routing routing;
	
	/**
	 * 工时状态manhourstate
	 */
	@Column(name = "MANHOURSTATE", precision = 10)
	protected Integer manhourState;
//	// many-to-one
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumnsOrFormulas(value = {
//			@JoinColumnOrFormula(column = @JoinColumn(name = "MANHOURSTATE", referencedColumnName = "ID", nullable = true, insertable = false, updatable = false)),
//			@JoinColumnOrFormula(formula = @JoinFormula(value = "'manhourstate'", referencedColumnName = "TYPESNAME")) })
//	protected TypesData manhourStateDesc;

	/**
	 * 工种optype
	 */
	@Column(name = "OPTYPE", precision = 10, scale = 0)
	protected Integer opType;
//	// many-to-one
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumnsOrFormulas(value = {
//			@JoinColumnOrFormula(column = @JoinColumn(name = "OPTYPE", referencedColumnName = "ID", nullable = true, insertable = false, updatable = false)),
//			@JoinColumnOrFormula(formula = @JoinFormula(value = "'optype'", referencedColumnName = "TYPESNAME")) })
//	protected TypesData opTypeDesc;

	@Column(name="SUSPENDED")
	protected Boolean isSuspended;
	
	@Column(name="LOCKED")
	protected Boolean isLocked;
	
	@Column(name = "NEEDCHECK", precision = 2, scale = 0)
	protected Boolean isNeedCheck;

	@Column(name = "SLACKFACTOR", precision = 10, scale = 2)
	protected Float slackFactor;

	@Column(name = "NONENEEDDISPATCH")
	protected Integer dispatchGrade;
	
	@Column(name = "WORKCENTERUID")
	protected String workCenterUid;
	// many-to-one
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "WORKCENTERUID", insertable = false, updatable = false)
	protected WorkCenter workCenter;

	@Column(name = "DEVICEUID")
	protected String deviceUid;
	// many-to-one
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "DEVICEUID", insertable = false, updatable = false)
	protected Device device;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "succOperationTask")
	protected Set<OperationTaskLink> predOperationTaskLinks;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "predOperationTask")
	protected Set<OperationTaskLink> succOperationTaskLinks;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "task")
	protected Set<TaskPart> taskParts;
	/**
	 * 加工记录
	 */
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "operationTask")
	protected Set<WorkRecord> workRecords;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "operationTask")
	protected Set<AssignmentWorkCenter> assignmentWorkCenters;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "operationTask")
	protected Set<AssignmentDevice> assignmentDevices;

	// @Formula("mmdn(ESTIPRETIME)")
	// protected Float calcPreTime;
	//
	// @Formula("mmdn(ESTIRUNTIME)")
	// protected Float calcRunTime;

//	@Formula("(select h.invDemandState from I_iodemand_header h where h.taskUid = TASKUID and rownum = 1)")
//	protected String invDemandState;

	// @Transient
	// protected List<String> availableResourceInOperationList;
	//
	// @Transient
	// protected List<String> availableResourceInHistoryList;

	@Column(name = "OPERATION_DISTANCE")
	protected Integer taskDistance;

	// @Column(name = "PREPARE_STATE")
	// protected String prepareState;
	// // many-to-one
	// @ForeignKey(name = "null")
	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumnsOrFormulas(value = {
	// @JoinColumnOrFormula(column = @JoinColumn(name = "PREPARE_STATE",
	// referencedColumnName = "ID", nullable = true, insertable = false,
	// updatable = false)),
	// @JoinColumnOrFormula(formula = @JoinFormula(value = "'prepare_state'",
	// referencedColumnName = "TYPESNAME")) })
	// protected TypesData prepareStateDesc;

	/**
	 * 是否关键
	 */
	@Column(name = "IS_CRITICAL_OPERATION")
	protected Boolean isCritical; // 是否关键件,改成Int支持多个关键级别

	@Column(name = "REASONCODE")
	protected String reasonCode;
	
	// 是否采用流水加工
	@Column(name = "ISTURNED")
	protected Boolean isFlow;

	
	
	/**
	 * 空的构造函数
	 */
	public OperationTask() {
	}

	/**
	 * 获取计划开始时间
	 * 
	 * @return
	 */

	public Date getPlanStart() {
		return planStart;
	}

	/**
	 * 设置计划开始时间
	 * 
	 * @param planstart
	 */
	public void setPlanStart(Date planStart) {
		this.planStart = planStart;
	}

	/**
	 * 获取计划结束时间
	 * 
	 * @return
	 */

	public Date getPlanFinish() {
		return planFinish;
	}

	/**
	 * 设置计划结束时间
	 * 
	 * @param planfinish
	 */
	public void setPlanFinish(Date planFinish) {
		this.planFinish = planFinish;
	}

	/**
	 * 获取派工的类型
	 * 
	 * @return
	 */

	public Integer getDispatchGrade() {
		return dispatchGrade;
	}

	/**
	 * 设置派工类型
	 * 
	 * @param noneneeddispatch
	 */
	public void setDispatchGrade(Integer dispatchGrade) {
		this.dispatchGrade = dispatchGrade;
	}

	/**
	 * 获取工序任务准备工时
	 *
	 * @return
	 */

	public Float getPreOpTime() {
		return this.preOpTime;
	}

	/**
	 * 设置工序任务准备工时
	 *
	 * @param preoptime
	 */
	public void setPreOpTime(Float preOpTime) {
		this.preOpTime = preOpTime;
	}

	/**
	 * 获取工序任务结束工时
	 *
	 * @return
	 */

	public Float getPostOpTime() {
		return this.postOpTime;
	}

	/**
	 * 设置工序任务结束工时
	 *
	 * @param postoptime
	 */
	public void setPostOpTime(Float postOpTime) {
		this.postOpTime = postOpTime;
	}

	/**
	 * 获取单件运行时间
	 *
	 * @return
	 */

	public Float getRunTime() {
		return runTime;
	}

	/**
	 * 设置单件运行时间
	 *
	 * @param runtime
	 */
	public void setRunTime(Float runTime) {
		this.runTime = runTime;
	}

	/**
	 * 获取排产任务工时
	 * 
	 * @return
	 */

	public Float getEstiTaskWork() {
		return estiTaskWork;
	}

	/**
	 * 设置排产任务工时
	 * 
	 * @param estitaskwork
	 */
	public void setEstiTaskWork(Float estiTaskWork) {
		this.estiTaskWork = estiTaskWork;
	}

	/**
	 * 获取工序号
	 * 
	 * @return
	 */

	public String getOperationIdDesc() {
		return operationIdDesc;
	}

	/**
	 * 设置工序号
	 * 
	 * @param operationIddesc
	 */
	public void setOperationIdDesc(String operationIdDesc) {
		this.operationIdDesc = operationIdDesc;
	}

	public Float getOperationId() {
		return operationId;
	}

	public void setOperationId(Float operationId) {
		this.operationId = operationId;
	}

	/**
	 * 获取对应工艺中的工序唯一号
	 * 
	 * @return
	 */

	public String getOperationUid() {
		return operationUid;
	}

	/**
	 * 设置工序唯一号
	 * 
	 * @param operationUid
	 */
	public void setOperationUid(String operationUid) {
		this.operationUid = operationUid;
	}

	/**
	 * 获取试件数量
	 * 
	 * @return
	 */

	public Float getTryQty() {
		return tryQty;
	}

	/**
	 * 设置试件数量
	 * 
	 * @param tryqty
	 */
	public void setTryQty(Float tryQty) {
		this.tryQty = tryQty;
	}

	/**
	 * 获取工时状态
	 * 
	 * @return
	 */

	public Integer getManhourState() {
		return manhourState;
	}

	/**
	 * 设置工时状态
	 * 
	 * @param manhourstate
	 */
	public void setManhourState(Integer manhourState) {
		this.manhourState = manhourState;
	}

	/**
	 * 获取工种类型
	 * 
	 * @return
	 */

	public Integer getOpType() {
		return opType;
	}

	/**
	 * 设置操作类型
	 * 
	 * @param optype
	 */
	public void setOpType(Integer opType) {
		this.opType = opType;
	}

	/**
	 * 获取工序是否需要检验标志
	 * 
	 * @return
	 */

	public Boolean getIsNeedCheck() {
		return isNeedCheck;
	}

	/**
	 * 设置工序是否需要检验
	 * 
	 * @param needcheck
	 */
	public void setIsNeedCheck(Boolean isNeedCheck) {
		this.isNeedCheck = isNeedCheck;
	}

	/**
	 * 获取加工中心Uid
	 * 
	 * @return
	 */

	public String getWorkCenterUid() {
		return workCenterUid;
	}

	/**
	 * 设置加工中心Uid
	 * 
	 * @param workcenterUid
	 */
	public void setWorkCenterUid(String workCenterUid) {
		this.workCenterUid = workCenterUid;
	}

	/**
	 * 获取设备Uid
	 * 
	 * @return
	 */

	public String getDeviceUid() {
		return deviceUid;
	}

	/**
	 * 设置设备Uid
	 * 
	 * @param DeviceUid
	 */
	public void setDeviceUid(String deviceUid) {
		this.deviceUid = deviceUid;
	}

	/**
	 * 获取工艺路线
	 * 
	 * @return
	 */

	public Operation getOperation() {
		return operation;
	}

	/**
	 * 设置工艺路线
	 * 
	 * @param operation
	 */
	public void setOperation(Operation operation) {
		this.operation = operation;
	}


	/**
	 * 获取工作中心对象
	 * 
	 * @return
	 */

	public WorkCenter getWorkCenter() {
		return workCenter;
	}

	/**
	 * 设置工作中心对象
	 * 
	 * @param workcenter
	 */
	public void setWorkCenter(WorkCenter workCenter) {
		this.workCenter = workCenter;
		this.workCenterUid = (workCenter != null) ? workCenter.getUuid() : null;
	}

	/**
	 * 获取设备对象
	 * 
	 * @return
	 */

	public Device getDevice() {
		return device;
	}

	/**
	 * 设置设备对象
	 * 
	 * @param device
	 */
	public void setDevice(Device device) {
		this.device = device;
	}

	// public Float getCalcPreTime() {
	// return calcPreTime;
	// }
	//
	// public void setCalcPreTime(Float calcPreTime) {
	// this.calcPreTime = calcPreTime;
	// }
	//
	// public Float getCalcRunTime() {
	// return calcRunTime;
	// }
	//
	// public void setCalcRunTime(Float calcRunTime) {
	// this.calcRunTime = calcRunTime;
	// }

	public Set<OperationTaskLink> getPredOperationTaskLinks() {
		return predOperationTaskLinks;
	}

	public void setPredOperationTaskLinks(Set<OperationTaskLink> predOperationTaskLinks) {
		this.predOperationTaskLinks = predOperationTaskLinks;
	}

	public Set<OperationTaskLink> getSuccOperationTaskLinks() {
		return succOperationTaskLinks;
	}

	public void setSuccOperationTaskLinks(Set<OperationTaskLink> succOperationTaskLinks) {
		this.succOperationTaskLinks = succOperationTaskLinks;
	}

	public Float getSlackFactor() {
		return slackFactor;
	}

	public void setSlackFactor(Float slackFactor) {
		this.slackFactor = slackFactor;
	}

	public Set<TaskPart> getTaskParts() {
		return taskParts;
	}

	public void setTaskParts(Set<TaskPart> taskParts) {
		this.taskParts = taskParts;
	}

	public Set<AssignmentWorkCenter> getAssignmentWorkCenters() {
		return assignmentWorkCenters;
	}

	public void setAssignmentWorkCenters(Set<AssignmentWorkCenter> assignmentWorkCenters) {
		this.assignmentWorkCenters = assignmentWorkCenters;
	}

	public Set<WorkRecord> getWorkRecords() {
		return workRecords;
	}

	public void setWorkRecords(Set<WorkRecord> workRecords) {
		this.workRecords = workRecords;
	}

	public Integer getTaskDistance() {
		return taskDistance;
	}

	public void setTaskDistance(Integer taskDistance) {
		this.taskDistance = taskDistance;
	}

	public Float getRejectQty() {
		return rejectQty;
	}

	public void setRejectQty(Float rejectQty) {
		this.rejectQty = rejectQty;
	}

	public Float getNoDefectQty() {
		return noDefectQty;
	}

	public void setNoDefectQty(Float noDefectQty) {
		this.noDefectQty = noDefectQty;
	}

	public Float getReworkQty() {
		return reworkQty;
	}

	public void setReworkQty(Float reworkQty) {
		this.reworkQty = reworkQty;
	}

	public Float getRepairQty() {
		return repairQty;
	}

	public void setRepairQty(Float repairQty) {
		this.repairQty = repairQty;
	}

	public Float getEstiPreOpTime() {
		return estiPreOpTime;
	}

	public Float getEstiRunTime() {
		return estiRunTime;
	}

	public void setEstiPreOpTime(Float estiPreopTime) {
		this.estiPreOpTime = estiPreopTime;
	}

	public void setEstiRunTime(Float estiRunTime) {
		this.estiRunTime = estiRunTime;
	}

	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.getTaskUid();
	}
	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.setTaskUid(uuid);
	}
	
	public String getTaskUid() {
		return taskUid;
	}

	public void setTaskUid(String taskUid) {
		this.taskUid = taskUid;
	}

	public Boolean getIsCritical() {
		return isCritical;
	}

	public void setIsCritical(Boolean isCritical) {
		this.isCritical = isCritical;
	}

	public boolean isFinished() {
		if (this.taskState != null) {
			if (this.taskState == TASKSTATE_COMPLETED || this.taskState == TASKSTATE_DELIVERIED) {
				return true;
			}
		}
		return false;
	}

	// public String getPrepareState() {
	// return prepareState;
	// }
	//
	// public void setPrepareState(String prepareState) {
	// this.prepareState = prepareState;
	// }
	//
	// public TypesData getPrepareStateDesc() {
	// return prepareStateDesc;
	// }
	//
	// public void setPrepareStateDesc(TypesData prepareStateDesc) {
	// this.prepareStateDesc = prepareStateDesc;
	// }

	public Boolean getIsFlow() {
		return isFlow;
	}

	public void setIsFlow(Boolean isFlow) {
		this.isFlow = isFlow;
	}

	public String getParentTaskUid() {
		return parentTaskUid;
	}

	public void setParentTaskUid(String parentTaskUid) {
		this.parentTaskUid = parentTaskUid;
	}

	public Set<AssignmentDevice> getAssignmentDevices() {
		return assignmentDevices;
	}

	public void setAssignmentDevices(Set<AssignmentDevice> assignmentDevices) {
		this.assignmentDevices = assignmentDevices;
	}

	@Override
	public String toString() {
		return this.taskUid;
	}

	public String toFriendlyString() {
		StringBuilder sb = new StringBuilder();

		if (this.part != null && this.part.getDrawingId() != null) {
			sb.append("图号：");
			sb.append(this.part.getDrawingId());
		}
		if (this.batchNum != null) {
			sb.append(" 批次：");
			sb.append(this.batchNum);
		}
		if (this.operationIdDesc != null && this.taskName != null) {
			sb.append(" 工序：");
			sb.append(this.operationIdDesc);
			sb.append(this.taskName);
		}
		return sb.toString();
	}

	public String getTaskName() {
		return taskName;
	}

	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	public Date getScheduleStart() {
		return scheduleStart;
	}

	public void setScheduleStart(Date scheduleStart) {
		this.scheduleStart = scheduleStart;
	}

	public Date getScheduleFinish() {
		return scheduleFinish;
	}

	public void setScheduleFinish(Date scheduleFinish) {
		this.scheduleFinish = scheduleFinish;
	}

	public Date getBaseStart() {
		return baseStart;
	}

	public void setBaseStart(Date baseStart) {
		this.baseStart = baseStart;
	}

	public Date getBaseFinish() {
		return baseFinish;
	}

	public void setBaseFinish(Date baseFinish) {
		this.baseFinish = baseFinish;
	}

	public Date getActualStart() {
		return actualStart;
	}

	public void setActualStart(Date actualStart) {
		this.actualStart = actualStart;
	}

	public Date getActualFinish() {
		return actualFinish;
	}

	public void setActualFinish(Date actualFinish) {
		this.actualFinish = actualFinish;
	}

	public Date getEarlyStart() {
		return earlyStart;
	}

	public void setEarlyStart(Date earlyStart) {
		this.earlyStart = earlyStart;
	}

	public Date getEarlyFinish() {
		return earlyFinish;
	}

	public void setEarlyFinish(Date earlyFinish) {
		this.earlyFinish = earlyFinish;
	}

	public Date getLateStart() {
		return lateStart;
	}

	public void setLateStart(Date lateStart) {
		this.lateStart = lateStart;
	}

	public Date getLateFinish() {
		return lateFinish;
	}

	public void setLateFinish(Date lateFinish) {
		this.lateFinish = lateFinish;
	}

	public Integer getConstraintType() {
		return constraintType;
	}

	public void setConstraintType(Integer constraintType) {
		this.constraintType = constraintType;
	}

	public Date getConstraintDate() {
		return constraintDate;
	}

	public void setConstraintDate(Date constraintDate) {
		this.constraintDate = constraintDate;
	}

	public Float getTaskWork() {
		return taskWork;
	}

	public void setTaskWork(Float taskWork) {
		this.taskWork = taskWork;
	}

	public Float getCompleteWork() {
		return completeWork;
	}

	public void setCompleteWork(Float completeWork) {
		this.completeWork = completeWork;
	}

	public String getTaskType() {
		return taskType;
	}

	public void setTaskType(String taskType) {
		this.taskType = taskType;
	}

	public Integer getTaskState() {
		return taskState;
	}

	public void setTaskState(Integer taskState) {
		this.taskState = taskState;
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public Float getCompletePercent() {
		return completePercent;
	}

	public void setCompletePercent(Float completePercent) {
		this.completePercent = completePercent;
	}

	public String getPartUid() {
		return partUid;
	}

	public void setPartUid(String partUid) {
		this.partUid = partUid;
	}

	public Part getPart() {
		return part;
	}

	public void setPart(Part part) {
		this.part = part;
	}

	public String getPartDrawingId() {
		return partDrawingId;
	}

	public void setPartDrawingId(String partDrawingId) {
		this.partDrawingId = partDrawingId;
	}

	public String getPartName() {
		return partName;
	}

	public void setPartName(String partName) {
		this.partName = partName;
	}

	public String getPartVersionId() {
		return partVersionId;
	}

	public void setPartVersionId(String partVersionId) {
		this.partVersionId = partVersionId;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getBatchNum() {
		return batchNum;
	}

	public void setBatchNum(String batchNum) {
		this.batchNum = batchNum;
	}

	public String getContignationNumber() {
		return contignationNumber;
	}

	public void setContignationNumber(String contignationNumber) {
		this.contignationNumber = contignationNumber;
	}

	public Float getPlanQty() {
		return planQty;
	}

	public void setPlanQty(Float planQty) {
		this.planQty = planQty;
	}

	public Float getDueQty() {
		return dueQty;
	}

	public void setDueQty(Float dueQty) {
		this.dueQty = dueQty;
	}

	public Float getCompleteQty() {
		return completeQty;
	}

	public void setCompleteQty(Float completeQty) {
		this.completeQty = completeQty;
	}

	public Boolean getIsSuspended() {
		return isSuspended;
	}

	public void setIsSuspended(Boolean isSuspended) {
		this.isSuspended = isSuspended;
	}

	public Boolean getIsLocked() {
		return isLocked;
	}

	public void setIsLocked(Boolean isLocked) {
		this.isLocked = isLocked;
	}

	
	public String getDeptUid() {
		return deptUid;
	}

	public void setDeptUid(String deptUid) {
		this.deptUid = deptUid;
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
	}

	public String getMasterShopUid() {
		return masterShopUid;
	}

	public void setMasterShopUid(String masterShopUid) {
		this.masterShopUid = masterShopUid;
	}

	public Dept getMasterShop() {
		return masterShop;
	}

	public void setMasterShop(Dept masterShop) {
		this.masterShop = masterShop;
	}

	public String getRoutingUid() {
		return routingUid;
	}

	public void setRoutingUid(String routingUid) {
		this.routingUid = routingUid;
	}

	public Routing getRouting() {
		return routing;
	}

	public void setRouting(Routing routing) {
		this.routing = routing;
	}

	public String getReasonCode() {
		return reasonCode;
	}

	public void setReasonCode(String reasonCode) {
		this.reasonCode = reasonCode;
	}

	public PartTask getPartTask() {
		return partTask;
	}

	public void setPartTask(PartTask partTask) {
		this.partTask = partTask;
	}

	@Override
	public boolean equals(Object obj) {
//		String otherUuid = (String) ((BasicModel) obj).getUuid();
//		String myUuid = (String) getUuid();
//		if (otherUuid.equals(myUuid)) {
//			return true;
//		} else {
//			return false;
//		}
		return false;
	}
	

	/**
	 * 大纲级别，用于设置优先级 hba
	 * aad by lcs 用于AO任务管理优先级展示
	 */
	@Column(name = "OUTLINELEVEL")
	protected String outLineLevel;

	public String getOutLineLevel() {
		return outLineLevel;
	}

	public void setOutLineLevel(String outLineLevel) {
		this.outLineLevel = outLineLevel;
	}
}
